# _*_ coding: utf-8 _*_
# @Time     : 2022/7/22 22:25
# @Author   : dake
# @Email    : dake@2545923.com
# @File     : sq_guanzhu.py
# @Software : PyCharm
from time import sleep
from appium import webdriver
from selenium.webdriver.common.by import By
desered_capabilities = {
    "platformName": "Android",  # 模拟器或真机的系统
    "deviceName": "127.0.0.1:62001",  # 系统版本号
    "platformVersion": "7.1.2",  # 设备名称，自定义设置
    "appPackage": "com.gfeng.daydaycook",  # app的包名
    "appActivity": "com.gfeng.daydaycook.activity.WelcomeActivity",  # app的activity
    "noReset": True,
    "unicodeKeyboard": True,
    "newCommandTimeout": 80,  # 等待时长
    "resetKeyboard": True  # 切换输入法
}

driver = webdriver.Remote("http://localhost:4723/wd/hub", desered_capabilities)
driver.implicitly_wait(20)
guanzhu = (By.ID, "com.gfeng.daydaycook:id/ll_attention")
quxiaoguanzhu = (By.ID, "com.gfeng.daydaycook:id/iv_focus_status")
# shoucang = (By.XPATH, '//@text="收藏"')
zuoping = (By.ID, "com.gfeng.daydaycook:id/item_bg")
xingxing = (By.CLASS_NAME, "android.widget.ImageView")
x = 990
y = 1810
driver.find_element_by_android_uiautomator('new UiSelector().text("我的")').click()
sleep(3)
# driver.find_element(*guanzhu).click()
# sleep(1)
# driver.find_elements(*quxiaoguanzhu)[1].click()
# sleep(4)
# driver.find_element(*guanzhu).click()
# sleep(2)
driver.find_element_by_android_uiautomator('new UiSelector().text("收藏")').click()
sleep(2)
driver.find_elements(*zuoping)[0].click()
sleep(3)
driver.tap([(x, y)])
sleep(5)
driver.quit()